package com.hotline.communication.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public enum RequestTypeEnum {

    GET_FILE_NAME(0,"获取录音文件名"),
    START_RECORDING(1,"开始录音"),
    END_RECORDING(2,"录音结束");

    /**
     * 编码
     */
    private Integer code;

    /**
     * 名称
     */
    private String name;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    RequestTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public static RequestTypeEnum getRequestTypeEnum(Integer code){
        for (RequestTypeEnum backlogTypeEnum : RequestTypeEnum.values()){
            if(backlogTypeEnum.getCode().equals(code)){
                return backlogTypeEnum;
            }
        }
        return null;
    }

    public static List getRequestTypeEnumList(){
        List list = new ArrayList();
        for (RequestTypeEnum backlogTypeEnum : RequestTypeEnum.values()){
            Map map = new HashMap<>();
            map.put("code",backlogTypeEnum.getCode());
            map.put("name",backlogTypeEnum.getName());
            list.add(map);
        }
        return list;
    }
}
